#if !defined(ximera_system_pluginmanager_hpp)
#define ximera_system_pluginmanager_hpp

// -----------------------------------------------------------

#include <ximera/types.hpp>
#include <ximera/common/sharedptr.hpp>
#include <ximera/system/iplugin.hpp>
#include <ximera/system/library.hpp>

#include <vector>
#include <map>

namespace ximera { namespace system
{
    #define XIMERA_PLUGIN(name) name L"." XIMERA_LIBRARY_EXT
    
    class XIMERA_API PluginManager
    {
    private:
        typedef std::vector<SharedPtr<Library> > LibraryVector;
        typedef std::map<String, SharedPtr<IPlugin> > PluginMap;
        
        LibraryVector _libraries;
        PluginMap _plugins;

    public:
        typedef PluginMap::const_iterator ConstIterator;
        typedef IPlugin* (InitFunctionType)();

    public:
        SharedPtr<IPlugin> loadPlugin(String const& library);
        SharedPtr<IPlugin> plugin(String const& name);

        ConstIterator begin() const;
        ConstIterator end() const;
    };
}}

// -----------------------------------------------------------

#endif